<template>
  <div class="searchlist">
    <el-form inline>
      <el-form-item v-for="(item,index) in searchList" :key="index" :label="item.label" :prop="item.name">
        <el-input v-model="item.value" v-if="item.type === 'input'"></el-input>
        <el-select v-model="item.value" v-if="item.type === 'select'">
          <el-option :label="list.label" :value="list.value" v-for="(list,index) in item.options"
                     :key="index"></el-option>
        </el-select>
        <el-date-picker placeholder="选择日期" v-model="item.value" v-if="item.type === 'date'"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="doSearch" icon="search">查询</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  export default {
    name: 'searchlist',
    props: {
      appendSearch: {
        type: Array,
        default () {
          return []
        }
      },
      authority: {
        type: Number,
        default () {
          return 15
        },
      }
    },
    data () {
      return {
        searchList: [],
        searchKinds: [{
          type: 'input',
          name: 'company_name',
          label: '公司名称',   //1
          value: ''
        }, {
          type: 'input',
          name: 'job_title',
          label: '岗位名称',  //2
          value: ''
        }, {
          type: 'input',
          name: 'name',
          label: '姓名',   //4
          value: ''
        }, {
          type: 'input',
          name: 'tel',
          label: '电话号码',  //8
          value: ''
        }, {
          type: 'select',
          name: 'education',
          label: '学历要求',  //16
          value: '',
          options: [{
            value: '6',
            label: '初中及以下'
          }, {
            value: '5',
            label: '高中'
          }, {
            value: '4',
            label: '职高/中专/技校'
          }, {
            value: '3',
            label: '大专'
          }, {
            value: '2',
            label: '本科'
          }, {
            value: '1',
            label: '硕士'
          }, {
            label: '博士',
            value: '0'
          }]
        }, {
          type: 'date',
          name: '',
          label: '登录时间',  //32
          value: ''
        }, {
          type: 'input',
          name: 'key_names',
          label: '摊位编号/名称',  //64
          value: ''
        }, {
          type: 'select',
          name: 'status',
          label: '状态',   //128
          value: '',
          options: [{
            value: '0',
            label: '可用'
          }, {
            value: '1',
            label: '不可用'
          }, {
            value: '2',
            label: '所有'
          }]
        }, {
          type: 'select',
          name: 'is_expired',
          label: '预约情况',  //256
          value: '',
          options: [{
            value: '0',
            label: '正在使用中'
          }, {
            value: '1',
            label: '未预约'
          }, {
            value: '2',
            label: '所有'
          }]
        }, {
          type: 'date',
          name: 'date_schedule',
          label: '预约时间',  //512
          value: ''
        }],
        searchData: {}
      }
    },
    created () {
      var i = 0
      var s
      let len = this.searchKinds.length
      this.searchList = []
      var m = parseInt(this.authority)
      for (i = 0; i < len; i++) {
        s = m & (1 << i)
        if (s !== 0) {
          this.searchList.push(this.searchKinds[i])
        }
      }
      if (this.appendSearch.length > 0) {
        this.appendSearch.forEach(val => this.searchList.push(val))
      }
    },
    methods: {
      doSearch () {
        this.searchList.forEach((e) => {
          if (e.value !== null && e.value !== undefined && e.value !== '') {
            this.searchData[e.name] = e.value
          }
        })
        this.$emit('returnData', this.searchData)
      }
    },
  }
</script>
<style scoped>

</style>
